package com.lfy.auth.controller;

import com.lfy.auth.domain.entity.UserEntity;
import com.lfy.auth.service.FileService;
import com.lfy.common.result.R;
import com.lfy.commons.anno.user.AutoUser;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 用户文件相关Controller
 * @author 吕飞扬
 */
@RequestMapping("/file")
@RestController
public class FileController {
    @Resource
    private FileService fileService;

    /**
     * 更换头像
     * @param user 用户
     * @param file 头像文件
     * @return R<文件地址>
     */
    @PostMapping("/up")
    public R<String> upLoad(@AutoUser UserEntity user, @RequestParam("file") MultipartFile file){

        return fileService.up(user,file);

    }
}
